package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ProjectBean;
import com.project.mapper.IProjectMapper;
import com.project.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProjectServiceImpl implements IProjectService {
    @Autowired
    private IProjectMapper mapper;
    private static final int PAGESIZE=2;
    @Override
    public void addProject(ProjectBean projectBean) {
        mapper.addProject(projectBean);
    }

    @Override
    public ProjectBean findById(int projectId) {
        return mapper.findById(projectId);
    }

    @Override
    public PageInfo<ProjectBean> cutByItem(int pagNo, String projectName, String projectState, String rules) {
        PageHelper.startPage(pagNo,PAGESIZE);
        PageInfo<ProjectBean> info = PageInfo.of(mapper.cutByItem(projectName, projectState, rules));
        return info;
    }

    @Override
    public List<ProjectBean> findByState(String state) {
        return mapper.findByState(state);
    }
}
